﻿using UnityEngine;
using System.Collections;

public class UITriggerNGUIEvent : UITriggerEvent 
{ 
    public enum NGUIEventType 
    {
       OnClick,
       OnSubmit,
       OnDoubleClick,
       OnHover,
       OnPress,
       OnSelect,
       OnScroll,
       OnDragStart,
       OnDrag,
       OnDragOver,
       OnDragOut,
       OnDragEnd,
       OnDrop,
       OnKey,
       OnTooltip
    } 
    public GameObject EventTriggerG;
    public NGUIEventType EventType;

    public override void OnLoad()
    {

        switch (EventType)
        {
            case NGUIEventType.OnClick:
                UIEventListener.Get(this.EventTriggerG).onClick += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDoubleClick:
                UIEventListener.Get(this.EventTriggerG).onDoubleClick += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDrag:
                UIEventListener.Get(this.EventTriggerG).onDrag += this.OnNGUIVectorEvent;
                break;
            case NGUIEventType.OnDragEnd:
                UIEventListener.Get(this.EventTriggerG).onDragStart += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDragOut:
                UIEventListener.Get(this.EventTriggerG).onDragOut += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDragOver:
                UIEventListener.Get(this.EventTriggerG).onDragOver += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDragStart:
                UIEventListener.Get(this.EventTriggerG).onDragStart += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnDrop:
                UIEventListener.Get(this.EventTriggerG).onDrop += this.OnNGUIObjectEvent;
                break;
            case NGUIEventType.OnHover:
                UIEventListener.Get(this.EventTriggerG).onHover += this.OnNGUIBoolEvent;
                break;
            case NGUIEventType.OnKey:
                UIEventListener.Get(this.EventTriggerG).onKey += this.OnNGUIKeyCodeEvent;
                break;
            case NGUIEventType.OnPress:
                UIEventListener.Get(this.EventTriggerG).onPress += this.OnNGUIBoolEvent;
                break;
            case NGUIEventType.OnScroll:
                UIEventListener.Get(this.EventTriggerG).onScroll += this.OnNGUIFloatEvent;
                break;
            case NGUIEventType.OnSelect:
                UIEventListener.Get(this.EventTriggerG).onSelect += this.OnNGUIBoolEvent;
                break;
            case NGUIEventType.OnSubmit:
                UIEventListener.Get(this.EventTriggerG).onSubmit += this.OnNGUIEvent;
                break;
            case NGUIEventType.OnTooltip:
                UIEventListener.Get(this.EventTriggerG).onTooltip += this.OnNGUIBoolEvent;
                break;
        }
    }
    public override bool EventCondition(Hashtable argDic)
    {
        return true;
    }

    public void OnNGUIEvent(GameObject go)
    {
        Hashtable hashDic = new Hashtable();
        hashDic.Add("EventType",this.EventType);
        UITriggerRoot.Inst().CallEvent(this.GetType(), hashDic);
    }
    public void OnNGUIVectorEvent(GameObject go,Vector2 v) 
    {
    
    }
    public void OnNGUIObjectEvent(GameObject go,GameObject go2) { }
    public void OnNGUIBoolEvent(GameObject go, bool b) { }
    public void OnNGUIKeyCodeEvent(GameObject go,KeyCode code) { }
    public void OnNGUIFloatEvent(GameObject go,float f) 
    {
    
    }
}
